//
// Created by Lenovo on 2023/10/2.
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 3e5+7;
int a[N],b[N];
void solve()
{
    int n,m,k;
    cin>>n>>m>>k;
    k%=2;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=m;i++)cin>>b[i];
    sort(a+1,a+1+n);
    sort(b+1,b+1+m);
    ll ans=0;
    if(a[1]>=b[m])
    {
        if(k%2==0)
        {
            swap(a[n],b[1]);
        }
    }
    else
    {
        if(k&1)swap(a[1],b[m]);
        else
        {
            a[1]=min(a[1],b[1]);
            a[n]=min(a[n],b[m]);
        }
    }
    for(int i=1;i<=n;i++)
    {
//		cout<<a[i]<<" ";
        ans+=a[i];
    }
//	cout<<endl;
    cout<<ans;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
        cout<<endl;
    }
    return 0;
}